Mathematica graphics

Graphics generated by Mathematica can be incorporated into TEX documents using Trevor Darrell's psfig TEX/LATEX macros [#!Darrell!#]. These are described fully in the detailed documentation provided as part of the psfig kit. (The epsf macros of Tomas Rokicki's program dvips [#!Rokicki!#] can be used instead.) Including graphics in a TEX/Mathematica document is a three-part process. First the psfig macro must be read in and initialized, then graphics are generated to files with appropriate PostScript bounding box information, and finally files are placed in the document.

Before Mathematica graphics files can be included in a TEX document, the psfig macro must be set up. For a TEX document use

	\input psfig
	...
	\psfiginit
For a LATEX document use

	\documentstyle[mathematica,psfig,...
	...
	\begin{document}
	...
	\psfiginit
The command \psfiginit must come before any use of \ psfig (see below); in LATEX documents \psfiginit also must come after \begin{document}.

Figures are incorporated via PostScript graphics files that contain the proper bounding box information. The Mathematica command PSTeX[-graphics-, "file"], defined in PSTeX.m, generates these graphics files. If PSTeX.m has not yet been read in (say by the Mathematica initialization file init.m), it can be loaded with \begin{mathematica}[* Initialization Cell *]
<<PSTeX.m
\end{mathematica} To save space, PSTeX does not include in the file the PostScript prolog containing Mathematica-specific definitions. This means that this prolog file must be downloaded to the printer before the file can be printed. This is done by the dvips processor, using \special commands inserted in the .dvi file by \psfiginit.

The figure is scaled to a height equal to PSTeXHeight points (72 points equal 1 inch), using a scheme developed by Cameron Smith [#!Smith!#]; the default height is 100 points. After the figure has been stored, the height can still be changed setting the height variable of \ psfig. However, if the height is determined by PSTeXHeight, the font size for labels is 7 points (or whatever the value of the variable PSTeXFontsize is); if the height is determined by the height variable, the whole figure is scaled, including the fonts.

Notice that a file generated by PSTeX generally should not be printed directly, because it does not incorporate the PostScript prolog file, because the figure is scaled in the way described above, and because the bounding box adjustment shifts the figure to the lower left corner of the page. The command PSFile, defined in PSFile.m, produces a graphic in a file, centered and scaled to fill the whole page.

The following example shows how to generate a figure to a file: \begin{mathematica}
fig = Plot[Sin[x]^3, {x, 0, 4Pi}]; \
PSTeXFontsize = 9; \
PSTeX[fig, ''sin3x''];
\end{mathematica} Use ESC ` " (M-x quoted-insert ") to insert a double quote in a TEX buffer. Notice that the suffix .ps is added automatically to the file name, and that the font size was changed from the default (7 points).

Finally, the figure can be placed in a LATEX document with commands like

	\begin{figure}
	\centerline{\psfig{figure=sin3x.ps}}
	\caption{{\sl Mathematica} plot of $\sin^3 x$.}
	\end{figure}
which produce the figure seen here.
Figure: Mathematica plot of sin3x.
\begin{figure}\centerline{\psfig{figure=sin3x.ps}}
\end{figure}
A macro is provided with TEX/Mathematica to place figures in a TEX document in a similar way.